//
//  HandleHistoryItemModel.m
//  Utils
//
//  Created by enghou on 2018/4/19.
//  Copyright © 2018年 xyxorigation. All rights reserved.
//

#import "HandleHistoryItemModel.h"

@implementation HandleHistoryItemModel
-(instancetype)initWithSource:(NSDictionary *)source{
    self = [super initWithSource:source];
    if (self) {
        self.event_desc = [self contentForKey:@"dealDescribe" withSource:source];
        self.time = [self contentForKey:@"dealTime" withSource:source];
        self.event_content = [self contentForKey:@"content" withSource:source];
        NSMutableArray *files = [NSMutableArray array];
        NSArray *f = [source objectForKey:@"files"];
        for (NSDictionary *element in f) {
            [files addObject:[[FileItemModel alloc]initWithSource:element]];
        }
        CGSize descSize = [self.event_desc caculateSizeWithFont:[UIFont systemFontOfSize:14] MaxSize:CGSizeMake(ScreenWidth - 30, CGFLOAT_MAX)];
        CGSize contentSize = [self.event_content caculateSizeWithFont:[UIFont systemFontOfSize:14] MaxSize:CGSizeMake(ScreenWidth - 30, CGFLOAT_MAX)];
        self.files = [files copy];
        self.height = 55 + descSize.height + contentSize.height;
        if ([self.files count] > 0) {
            self.height += 108;
        }
        
        //15 + 16 + 8 + height1 + 8 + height2 + 8 + (100 +8)
    }
    return self;
}
@end
